﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LeadVinaglue.Models;
using LeadVinaglue.Models.ViewPages;
using LeadVinaglue.Repository;
using LeadVinaglue.Utility;

namespace LeadVinaglue.Controllers
{
    public class BusinessController : Controller
    {
        LEManagementRepository repository = new LEManagementRepository();
        // GET: /Business/

        [DeviceFilterAttribute(Order = 1)]
        public ActionResult Index(int? page)
        {
            LEManagementModel model = new LEManagementModel();
            
            // Build params
             int pageIndex = (page == null) ? 1 : Convert.ToInt32(page.ToString()), pageSize = 8, count = 0;
            string url = Request.RawUrl.ToLower();
            if (url.IndexOf("?page=") > -1)
                url = url.Substring(0, url.IndexOf("?page="));
            url = url + "?page={0}";

            model = repository.GetBusinessModel(LeadConstant.BUSINESS, url, pageIndex, pageSize, ref count); 

            return View(model);
        }
    }
}
